package com.atguigu.controller;


import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.atguigu.config.websocket1.MyWebSocketHandler;
import com.atguigu.service.HelloService;
import com.atguigu.utils.FileUtil;
@Controller
public class HelloController {
	
	@Autowired
	HelloService helloService;
	@Autowired
	MyWebSocketHandler myHandler;
	
	@ResponseBody
	@RequestMapping("/hello")
	public String hello(){
		String hello = helloService.sayHello("tomcat..");
		return hello;
	}
	
	@RequestMapping("/index")
	public String index(){
		//String hello = helloService.sayHello("tomcat..");
		return "index";
	}
	
	
	//  /WEB-INF/views/success.jsp
	@RequestMapping("/suc")
	public String success(){
		System.out.println("-------- success ---------");
		return "success";
	}
	
	@RequestMapping(value = "/importQuestions",method = RequestMethod.POST)
	@ResponseBody
	public String importQuestions(HttpServletRequest request,HttpServletResponse resp,String fileNames) {
		resp.setContentType("text/html; charset=utf-8");
		
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return "success";
	}  
}
